#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using std::cin;
using std::cout;
using std::vector;

template<typename Iter, typename Comp>
Iter Merge(Iter begin1, Iter end1, Iter begin2, Iter end2, Iter out, Comp cmp) {
	while (begin1 != end1 && begin2 != end2) {
		if (cmp(*begin1, *begin2)) {
			*out = *begin1;
			++begin1;
			++out;
		}
		else {
			*out = *begin2;
			++begin2;
			++out;
		}
	}
	if (begin2 == end2) {
		while (begin1 != end1) {
			*out = *begin1;
			++begin1;
			++out;
		}
	}
	else {
		while (begin2 != end2) {
			*out = *begin2;
			++begin2;
			++out;
		}
	}
	return out;
}

template<typename T>
void Input(std::istream &input, vector<T> &sequence) {
	size_t size;
	input >> size;
	sequence.resize(size);
	for (size_t index = 0; index < size; ++index) {
		input >> sequence[index];
	}
}

template<typename T>
void Output(std::ostream &output, vector<T> &sequence) {
	for (size_t index = 0; index < sequence.size(); ++index) {
		output << sequence[index] << " ";
	}
}

int main() {
	vector<int> sequence1, sequence2;
	Input(cin, sequence1);
	Input(cin, sequence2);
	vector<int> result(sequence1.size() + sequence2.size());
	Merge(sequence1.begin(), sequence1.end(), sequence2.begin(), sequence2.end(), result.begin(), std::less<int>());
	Output(cout, result);
}
